const mongoose = require('mongoose');
const mongoURI = 'mongodb://127.0.0.1:27017/repair_system';
const mongoOptions = {
 
  serverSelectionTimeoutMS: 5000,
  socketTimeoutMS: 45000
};

// 定义模式
const repairSchema = new mongoose.Schema({
  title: String,
  description: String,
  status: String,
  created_at: Date,
  images: [String]   // 存储图片的地址
});


// 创建模型
const Repair = mongoose.model('Repair', repairSchema);
//导出模型
module.exports = Repair;
// 连接数据库
mongoose.connect(mongoURI, mongoOptions)
  .then(() => {
    console.log('MongoDB connected');   
    
  })
  .catch(err => console.error(`MongoDB connection error: ${err}`));
